<template>
    <div>
        <button @click="handleJump">跳过{{num}}</button>
    </div>
</template>

<script>
    export default {
        name:'Welcome',
        data() {
            return {
                num:3,
                timer:null
            }
        },
        mounted() {
            this.setCount()
        },
        methods: {
            setCount(){
                var num = this.num
                this.timer = setTimeout(()=>{
                    num--;
                    if(num>=0){
                        if(num==0){
                            this.$router.push('/home')
                        }
                        this.num = num
                    }
                    this.setCount()
                },1000)
            },
            handleJump(){
                clearTimeout(this.timer)
                this.$router.push('/home')
            }
        }
    }
</script>

<style scoped>

</style>